package org.dce.screencapturer.objects;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;

public class LineAttributes 
	extends PaintAttributes{
	
	private Color color = Color.BLACK;
	private BasicStroke stroke = new BasicStroke(2);
	
	private Color currentColor;
	private Stroke currentStroke;
	
	public LineAttributes(){
		setEnabled(true);
	}
	
	public LineAttributes(boolean enabled, int transparency, Color color, BasicStroke stroke){
		super(enabled,transparency);
		this.color = color;
		this.stroke = stroke;
	}
	
	public Color getColor() {
		return color;
	}
	public void setColor(Color color) {
		this.color = color;
	}
	public BasicStroke getStroke() {
		return stroke;
	}
	public void setStroke(BasicStroke stroke) {
		this.stroke = stroke;
	}
	
	public void apply(Graphics2D g2d){
		
		currentColor = g2d.getColor();
		currentStroke = g2d.getStroke();
		
		g2d.setColor(color);
		if (stroke != null){
			g2d.setStroke(stroke);
		}
	}
	
	@Override
	public void restore(Graphics2D g2d) {
		super.restore(g2d);
		g2d.setColor(currentColor);
		g2d.setStroke(currentStroke);
	}

	public Object clone(){
		return new LineAttributes(isEnabled(), getTransparency(), color, stroke);
	}
}
